<template>
  <div class="app-container">
    <el-card class="content-edit">
      <div slot="header">新增原因</div>
      <el-form ref="form" :model="form" label-width="140px">
        <el-form-item label="适用类型">
          <el-radio-group v-model="form['type']">
            <el-radio :label="0">通用</el-radio>
            <el-radio :label="1">机场接送</el-radio>
            <el-radio :label="2">巴士路线</el-radio>
            <el-radio :label="3">专车接送</el-radio>
            <el-radio :label="4">包车路线</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="拒绝原因">
          <el-input v-model="form['content']" type="textarea" rows="3"/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
          <el-button @click="$router.back()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'CustomerServiceTelephone',
    data() {
      return {
        form: {
          // 适用类型
          type: 1,
          // 内容
          content: ''
        }
      }
    },
    mounted(){
      this.loadData();
    },
    methods: {
      // 加载默认头像列表
      loadData(){
        // (async () => {
        //   const result = await this.$service.adminApplicationTagGetTagTree();
        //   if (result.code === 0) {
        //     //  13
        //   }
        // })();
      },
      // 提交
      onSubmit() {
        this.$refs.form.validate(valid => {
          if (valid) {
            this.loading = true;
            (async () => {
              const params = Object.assign({}, this.form);
              const result = await this.$service.applicationAddReason(params);
              this.loading = false;
              if (result.code === 0) {
                this.$message.success('操作成功~');
                this.$router.back();
              } else {
                this.$message.error(result.msg);
              }
            })();
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      }
    }
  }
</script>
